<template>
  <img alt="Vue logo" src="./assets/logo.png">
  <HelloWorld msg="Welcome to Your Vue.js App"/>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue'
const ffi = require('ffi-napi')
const path = require('path')
let { arch } = process // x64

//默认加载 32位 DLL
let dllFilePath = path.resolve('resources/DLLTEST')
if (arch === 'x64') {
  dllFilePath = path.resolve('resources/DLLTEST')
}


// 加载 DLL文件,无需写扩展名,将DLL中的函数映射成JS方法
// 导出为JS方法
const MyDellDemo = new ffi.Library(dllFilePath, {
  // 方法名必须与C函数名一致
  add: [
    'int', // 对应 C函数返回类型
    ['int', 'int'] // C函数参数列表
  ],
  addPtr: ['void', ['int', 'int', 'int*']]
})
console.log(MyDellDemo.add(1, 2))
export default {
  name: 'App',
  components: {
    HelloWorld
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
